// 增加modeler监听事件
//shape.added 新增一个shape之后触发;
// shape.move.end 移动完一个shape之后触发;
// shape.removed 删除一个shape之后触发;

export function addModelerListener(bpmnModeler) {
  const bpmnjs = bpmnModeler;

  // modeler需要绑定的事件
  const modelEvents = [
    "shape.added",
    "shape.move.end",
    "shape.removed",
    "connect.end",
    "connect.move"
  ];
  modelEvents.forEach(event => {
    bpmnjs.on(event, e => {
      console.log(event, e);
      var elementRegistry = bpmnjs.get("elementRegistry");
      var shape = e.element ? elementRegistry.get(e.element.id) : e.shape;
      console.log(shape);
    });
  });
}
